package com.example.hjt_java_web_homework2.domain.model;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @author 洪钧韬
 * @date 31/10/2025
 * @description
 */
@Entity
@Table(name = "air_conditioners")
public class AirConditioner extends Device {
    private Double temperature;
    private String mode; // COOL, HEAT, FAN, AUTO
    private Integer fanSpeed;

    public AirConditioner() {}

    public AirConditioner(String name, String location, String deviceId) {
        super(name, location, deviceId);
        this.temperature = 26.0;
        this.mode = "AUTO";
        this.fanSpeed = 2;
    }

    // 业务方法
    public void adjustTemperature(Double temperature) {
        if (temperature >= 16.0 && temperature <= 30.0) {
            this.temperature = temperature;
        }
    }

    public void switchMode(String mode) {
        if (mode != null && (mode.equals("COOL") || mode.equals("HEAT") ||
                mode.equals("FAN") || mode.equals("AUTO"))) {
            this.mode = mode;
        }
    }

    // Getters and Setters
    public Double getTemperature() { return temperature; }
    public void setTemperature(Double temperature) { this.temperature = temperature; }
    public String getMode() { return mode; }
    public void setMode(String mode) { this.mode = mode; }
    public Integer getFanSpeed() { return fanSpeed; }
    public void setFanSpeed(Integer fanSpeed) { this.fanSpeed = fanSpeed; }
}
